@extends('/admin/Layout/layout')
@section('title','商品修改')
@section('content')

<div id="page-wrapper" >
	<div class="row">
	    <div class="col-lg-2">
	        <h1 class="page-header">商品修改</h1>
	    </div>
		<div class="col-lg-10">
        	@if( count($errors) > 0 )
        		<div class='alert alert-danger alert-dismissable col-lg-12'>
        		<button class="close" type="button" data-dismiss="alert" aria-hidden="true">×</button>
        		<ul style='list-style:none;padding:0;margin:0;'>
				@foreach( $errors->all() as $k=>$error)
					<li>{{$error}}</li>
				@endforeach
				</ul>
				</div>
        	@endif
	    </div>
	    <!-- /.col-lg-12 -->
	</div>

	<div class='row'>
		 <div class="panel panel-default col-lg-8 col-lg-offset-2">
	        <div class="panel-body">
				<div class='row'>
					<div class="col-lg-10 col-lg-offset-1">
			        	<form role="form" action="{{asset('/admin/goods/update')}}"  method='post' enctype='multipart/form-data'>
			                <div class="form-group">
			                    <label>商品名称：</label>
			                    <input class="form-control" placeholder="必填" required name="gname" value="{{$goods->gname}}">
			                    <p class="help-block"></p>
			                </div>
			                <div class="form-group">
			                    <label>商品类别</label>
			                    <select class="form-control" name="tid">
			                        <option value='0' @if($goods->tid == null) selected @endif >未分类</option>
			                        @foreach($cates as $k=>$v)
			                        <option value='{{$v->tid}}' @if($v->tid == $goods->tid) selected @endif >{{$v->tname}}</option>
			                        @endforeach
			                    </select>
			                </div>
			                <label>价格：</label>
			                <div class="form-group input-group">
			                    <span class="input-group-addon">$</span>
			                    <input class="form-control" name="price" type="text" value="{{$goods->price}}" >
			                    <span class="input-group-addon">.00</span>
			                </div>
			                <div class="form-group">
			                    <label>库存：</label>
			                    <input class="form-control" name="cnt" required  type="text" value="{{$goods->cnt}}" >
			                </div>
			                <div class="form-group">
			                    <label>品牌：</label>
			                    <input class="form-control" name="gbrand" required  type="text" value="{{$goods->gbrand}}" >
			                </div>
			                <div class="form-group">
			                	<label>折扣：</label>
			                    <input class="form-control" name="dcont" required  type="text" value="{{$goods->dcont}}" >
			                </div>
			                <div class="form-group">
                                <label>尺码：</label>

								<label class="checkbox-inline">
	                                <input type="checkbox" name='gsize[]' @if(strstr($goods->gsize,'34')) checked @endif value='34'>34
	                            </label>
                                <label class="checkbox-inline">
	                                <input type="checkbox" name='gsize[]' @if(strstr($goods->gsize,'35')) checked @endif value='35'>35
	                            </label>
	                            <label class="checkbox-inline">
	                                <input type="checkbox" name='gsize[]' @if(strstr($goods->gsize,'36')) checked @endif value='36'>36
	                            </label>
	                            <label class="checkbox-inline">
	                                <input type="checkbox" name='gsize[]' @if(strstr($goods->gsize,'37')) checked @endif  value='37'>37
	                            </label>
	                            <label class="checkbox-inline">
	                                <input type="checkbox" name='gsize[]' @if(strstr($goods->gsize,'38')) checked @endif  value='38'>38
	                            </label>
	                            <label class="checkbox-inline">
	                                <input type="checkbox" name='gsize[]' @if(strstr($goods->gsize,'39')) checked @endif  value='39'>39
	                            </label>
	                            <label class="checkbox-inline">
	                                <input type="checkbox" name='gsize[]' @if(strstr($goods->gsize,'40')) checked @endif  value='40'>40
	                            </label>
	                            <label class="checkbox-inline">
	                                <input type="checkbox" name='gsize[]' @if(strstr($goods->gsize,'41')) checked @endif value='41'>41
	                            </label>
	                            <label class="checkbox-inline">
	                                <input type="checkbox" name='gsize[]' @if(strstr($goods->gsize,'42')) checked @endif  value='42'>42
	                            </label>
	                            <br>
	                            <label class="checkbox-inline">
	                                <input type="checkbox" name='gsize[]' @if(strstr($goods->gsize,'43')) checked @endif  value='43'>43
	                            </label>
	                            <label class="checkbox-inline">
	                                <input type="checkbox" name='gsize[]' @if(strstr($goods->gsize,'44')) checked @endif  value='44'>44
	                            </label>
	                            <label class="checkbox-inline">
	                                <input type="checkbox" name='gsize[]' @if(strstr($goods->gsize,'45')) checked @endif   value='45'>45
	                            </label>
	                            <label class="checkbox-inline">
	                                <input type="checkbox" name='gsize[]' @if(strstr($goods->gsize,'46')) checked @endif  value='46'>46
	                            </label>
			                <div class="form-group">
			                    <label>图片名称：</label>
			                    <input type="file" name="gpic"  >
			                    @if(!$goods->gpic == null )
                                    <img src="{{asset($goods->gpic)}}" width='100px' height="100px">
                                @endif
			                </div>
			                <input type="hidden" name="gid" value="{{$goods->gid}}">
						<script type="text/javascript" charset="utf-8" src="/ueditor/ueditor.config.js"></script>
					    <script type="text/javascript" charset="utf-8" src="/ueditor/ueditor.all.min.js"> </script>
					    <!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
					    <!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
					    <script type="text/javascript" charset="utf-8" src="/ueditor/lang/zh-cn/zh-cn.js"></script>
			                <div class="form-group">
			                    <label>商品描述：</label>
			                     <script id="editor"  type="text/plain" style="width:500px;height:300px;">{!!$goods->gdesc!!}</script>
			                </div>
			                {{csrf_field()}}
			                <button type="submit" class="btn btn-primary">提交</button>
			                <button type="reset" class="btn btn-warning">重置</button>
			            </form>
			        </div>
			    </div>
			</div>
		</div>
	</div>
</div>
@endsection
@section('js')
<script type="text/javascript">
	//实例化编辑器
    //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
    var ue = UE.getEditor('editor');

</script>
@endsection